package application;

import application.dao.DBService;
import application.dao.entity.News;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;

import java.util.List;

public class Athlete_news_controller extends BaseController {

    @FXML
    public MenuItem menu_informations_news;
    @FXML
    public ListView listNews;
    @FXML
    private Menu menu_enroll;

    @FXML
    private Menu menu_main;

    @FXML
    private MenuItem menu_informations_announcements;

    @FXML
    private Menu menu_person;

    @FXML
    private Menu menu_scores;

    @FXML
    void onCheckMenu_main(ActionEvent event) {

    }

    @FXML
    void onCheckMenu_person(ActionEvent event) {

    }

    @FXML
    void onCheckMenu_enroll(ActionEvent event) {

    }

    @FXML
    void onCheckMenu_scores(ActionEvent event) {

    }

    @FXML
    void onCheckMenu_informations_announcements(ActionEvent event) {

    }

    @FXML
    void onCheckMenu_informations_news(ActionEvent event) {

    }


    @Override
    public void init() {
        List<News> news = DBService.listNews();
        if (null != news) {
            for (News item : news) {
                Label label = new Label(item.getNewsTitle() + "\t" + BaseUtil.formatDate(item.getPubTime()));
                label.setAlignment(Pos.CENTER_LEFT);
                listNews.getItems().add(label);
            }
        }
    }
}